#include<bits/stdc++.h>
using namespace std;
#define OK 1
#define ERROR 0
typedef int Status;
typedef struct LNode{
	int data;
	LNode *next;	
}LNode, *LinkList; 

Status Create(LinkList &L, int n)
{
	L = new LNode;
	if(!L) return ERROR;
	cin >> L->data;
	L->next = NULL;
	LNode *t = L;
	for(int i = 0; i < n - 1; i ++)
	{
		LNode *p = new LNode;
		if(!p) return ERROR;
		cin >> p->data;
		p->next = t->next;
		t->next = p;
		t = p;
	}
	return OK;
}
/*************Begin************/
// 删除链表中所有的x元素
// 创建虚拟头节点
void Del_x(LinkList &L, int x)
{
    LNode *h = new LNode;
    h->next = L;
    LNode *pre = h;
    while(pre->next)
    {
        if(pre->next->data == x)
        {
        	LNode *t = pre->next;
        	pre->next = t->next;
        	delete t;
		}
		else
		{
			pre = pre->next;
		}
    }
    L = h->next; // 必不可少 
    delete h;
}
/**********End**************/
void Show(LinkList L)
{
	LNode *p = L;
	while(p)
	{
		cout << p->data << ' ';
		p = p->next;
	}
	cout << endl;
}
int main()
{
	LinkList L;
	int n;
	cin >> n;
	Create(L, n);
	int x;
	cin >> x;
	Del_x(L, x);
	Show(L);
	return 0;
}